IF EXISTS (
       SELECT *
       FROM   sys.objects
       WHERE  OBJECT_ID = OBJECT_ID(N'[dbo].[cms_sp_MediaFileRemoveByIds]')
              AND TYPE IN (N'P' ,N'PC')
   )
    DROP PROCEDURE [dbo].[cms_sp_MediaFileRemoveByIds]
GO

CREATE PROCEDURE [dbo].[cms_sp_MediaFileRemoveByIds] 
(@Ids NVARCHAR(500))
AS
BEGIN
	DELETE 
	FROM   MediaFiles
	WHERE  MediaFileId IN (SELECT cusi.integer
	                       FROM   dbo.cms_udf_SplitIntegers(@ids) cusi)
END
GO